package pri.syl.xiaowu.websocket.netty.server.thread;


import pri.syl.xiaowu.websocket.core.template.WebsocketChannelTemplate;
import pri.syl.xiaowu.websocket.core.template.WebsocketRouteTemplate;
import lombok.Getter;
import lombok.Setter;

/**
 * @Author YunLong
 * @Date 2021/7/18 19:28
 * @Description  关闭抽象线程
 **/
@Getter
@Setter
public abstract class AbstractWebsocketServerCloseThread implements Runnable {
    private WebsocketRouteTemplate websocketRouteTemplate;
    private WebsocketChannelTemplate websocketChannelTemplate;

    public AbstractWebsocketServerCloseThread(WebsocketRouteTemplate websocketRouteTemplate, WebsocketChannelTemplate websocketChannelTemplate) {
        this.websocketRouteTemplate = websocketRouteTemplate;
        this.websocketChannelTemplate = websocketChannelTemplate;
    }

    /**
     * close
     *
     * @param websocketRouteTemplate   websocketRouteTemplate
     * @param websocketChannelTemplate websocketChannelTemplate
     */
    protected abstract void close(WebsocketRouteTemplate websocketRouteTemplate, WebsocketChannelTemplate websocketChannelTemplate);

    @Override
    public void run() {
        close (this.websocketRouteTemplate, this.websocketChannelTemplate);
    }
}
